package com.dingding.api.controller.car;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.dingding.common.core.base.controller.BaseController;
import com.dingding.common.core.base.dto.FacadeResult;
import com.dingding.common.core.base.dto.ResponseEntity;
import com.dingding.facade.user.dto.car.ReqGetCarBrands;
import com.dingding.facade.user.dto.car.ReqGetCarModels;
import com.dingding.facade.user.dto.car.ResGetCarBrands;
import com.dingding.facade.user.dto.car.ResGetCarModels;
import com.dingding.facade.user.service.car.ICarBrandModelFacade;

/**
 * @Description:车辆选择服务的控制器
 * @author fengshuonan
 * @date 2016年10月25日 下午4:41:04
 * @version 叮叮搭车
 * @since 2.4
 */
@Scope("prototype")
@Controller("carSelectController")
@RequestMapping("/authorapi/carSelect")
public class CarSelectController extends BaseController{

	@Resource(name = "carBrandModelFacade")
	private ICarBrandModelFacade carBrandModelFacade;
	
	/**
	 * @Description:获取所有车辆品牌
	 * @author fengshuonan
	 * @since 2.4
	 */
	@RequestMapping(value = "/v1/getBrands", method = RequestMethod.POST)
	public void getBrands(HttpServletRequest request, HttpServletResponse response) {

		// 获取客户端数据
		ReqGetCarBrands reqGetCarBrands = super.getRequestBean(request, response, ReqGetCarBrands.class);
		
		// 执行业务处理，并返回处理后的数据
		FacadeResult<ResGetCarBrands> facadeResult = this.carBrandModelFacade.getCarBrands(reqGetCarBrands.getCarBrandNum());
		
		// 加密数据，并返回给客户端
		super.generateFacadeResponse(response, new ResponseEntity<ResGetCarBrands>(), facadeResult);
		
	}
	
	/**
	 * @Description:获取某个车辆品牌所有的车型
	 * @author fengshuonan
	 * @since 2.4
	 */
	@RequestMapping(value = "/v1/getModels", method = RequestMethod.POST)
	public void getModels(HttpServletRequest request, HttpServletResponse response) {

		// 获取客户端数据
		ReqGetCarModels reqGetCarModels = super.getRequestBean(request, response, ReqGetCarModels.class);
		
		// 执行业务处理，并返回处理后的数据
		FacadeResult<ResGetCarModels> facadeResult = this.carBrandModelFacade.getCarModels(reqGetCarModels.getCarBrandId());
		
		// 加密数据，并返回给客户端
		super.generateFacadeResponse(response, new ResponseEntity<ResGetCarModels>(), facadeResult);
		
	}
	
}
